<js href="__PUBLIC__/js/jquery-2.0.2.js" />
<js href="__PUBLIC__/ueditor/ueditor.config.js" />    
<js href="__PUBLIC__/ueditor/ueditor.all.min.js" />
<script>
$(function(){
    var ue = UE.getEditor('container',{
        serverUrl :'{:U("Home/user/ueditor")}'
    });
})
</script>
<input type="hidden" value="<?php echo $_SESSION['uid'] ?>" id="setsession">
<div class="wrap">

    <div class="post-topheader">
        <div class="container">
            <div class="row">
                <div class="col-md-9 col-sm-8 col-xs-12">
                    <span class="post-topheader__title--icon-symbol">问</span>
                    <div class="post-topheader__info">
                        <h1 class="h3 post-topheader__info--title" id="questionTitle" data-id="1010000005768307">
                            <a href="/q/1010000005768307">{$question['title']}</a>
                        </h1>
                        <ul class="taglist--inline inline-block question__title--tag mr10">
                            <volist name="cateTagArr" id="vo">
                                <li class="tagPopup mb5">
                                    <a class="tag" href="/t/express" data-toggle="popover" data-img="" data-placement="top" data-original-title="express" data-id="1040000000166256">{$vo.cname}</a>
                                </li>
                            </volist> 
                        </ul>
                        <div class="question__author">
                            <a href="/u/smoke" class="mr5"><strong>{$question['username']}</strong></a>
                            2 天前提问<span class="hidden-xs"></span>
                        </div>
                    </div>
                </div>

                <div class="col-md-3 col-sm-4 col-xs-12 hidden-xs">
                    <ul class="post-topheader__side list-unstyled">
                        <li>
                            <button type="button" id="sideFollow" class="btn btn-success btn-sm" data-id="1010000005768307" data-do="follow" data-type="question" data-toggle="tooltip" data-placement="right" title="" data-original-title="关注后将获得更新提醒">关注</button>
                            <strong>{$question['focus_num']}</strong> 关注
                        </li>
                        <li>
                            <button type="button" id="sideBookmark" class="btn btn-default btn-sm" data-id="1010000005768307" data-type="question">收藏</button>
                            <strong id="sideBookmarked">{$question['fav_num']}</strong> 收藏，<strong class="no-stress">{$question['view']}</strong> 浏览
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <!-- end .post-topheader -->

    <div class="container mt30">
        <div class="row">
            <div class="col-xs-12 col-md-9 main">
                <article class="widget-question__item">
                    <div class="post-col">
                        <div class="widget-vote" id="question_cate" clickType="question" dataid="<?php echo $_GET['qid'] ?>">
                            <button type="button" class="like" data-id="1010000005768307" data-type="question" data-do="like" data-toggle="tooltip" data-placement="top" title="" data-original-title="问题对人有帮助，内容完整，我也想知道答案">
                            <span class="sr-only">问题对人有帮助，内容完整，我也想知道答案</span>
                            </button>
                            <span class="count">{$question['vote_num']}</span>
                            <button type="button" class="hate" data-id="1010000005768307" data-type="question" data-do="hate" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="问题没有实际价值，缺少关键内容，没有改进余地">
                            <span class="sr-only">问题没有实际价值，缺少关键内容，没有改进余地</span>
                            </button>
                        </div>
                        <!-- end .widget-vote -->
                    </div>

                    <div class="post-offset">
                        <div class="question fmt" data-id="1010000005768307">                                        
                 {$question['content']}
<!-- <pre class="hljs"><div class="widget-codetool" style="display:none;"><button class="selectCode btn btn-xs">全选</button><button href="javascript:void(0);" class="copyCode btn btn-xs" data-clipboard-text="返回页面后不更新数据。（删掉的数据还显示）" data-toggle="tooltip" data-placement="bottom" title="">复制</button><button href="javascript:void(0);" class="saveToNote btn btn-xs">放进笔记</button></div><code style="word-break: break-word; white-space: initial;">返回页面后不更新数据。（删掉的数据还显示）</code></pre> -->
                        </div>                                                                                           
                        <div class="row">
                            <div class="post-opt col-md-8">
                                <ul class="list-inline mb0">
                                    <li><a href="/q/1010000005768307"><?php echo date("Y-m-d h:i:s",$question['create_time'])  ?>  提问</a></li>
                                    <li><a href="javascript:void(0);" class="comments" data-id="1010000005768307" data-target="#comment-1010000005768307">评论</a></li>
                                    <!-- <li class="edit-btn" data-original-title="" title="">
                                        <a class="inviteBtn" href="javascript:;" data-title="express执行mysql删除语句后，刷新页面不更新" data-url="http://sfau.lt/bNymLn" data-id="1010000005768307">邀请回答</a>
                                    </li> -->
                                </ul>
                            </div>   
                        </div>
                        <div class="widget-comments hidden" id="comment-1010000005768307" data-id="1010000005768307">
                            <div class="widget-comments__form row">
                                <div class="col-md-12">请先 <a class="commentLogin" href="javascript:void(0);">登录</a> 后评论</div>
                            </div><!-- /.widget-comments__form -->
                        </div><!-- /.widget-comments -->
                    </div>
                    <!-- end .post-offset -->
                </article>

                <div class="widget-answers">
                    <div class="btn-group pull-right" role="group">
                        <a href="/q/1010000005768307#answers-title" id="sortby-rank" class="btn btn-default btn-xs active">默认排序</a>
                        <a href="?sort=created#answers-title" id="sortby-created" class="btn btn-default btn-xs">时间排序</a>
                    </div>

                    <h2 class="title h4 mt30 mb20 post-title" id="answers-title">{$question['answer_num']} 个回答</h2>
                    <div></div>

                    <volist name="answerResult" id="answervo">
                        <article class="clearfix widget-answers__item" id="a-1020000005776083">
                            <div class="post-col">
                                <div class="widget-vote" id="answer_cate" clickType="answer" dataid="<?php echo $answervo["id"] ?>" >
                                    <button type="button" class="like" data-id="1020000005776083" data-type="answer" data-do="like" data-toggle="tooltip" data-placement="top" title="" data-original-title="答案对人有帮助，有参考价值">
                                        <span class="sr-only">答案对人有帮助，有参考价值</span>
                                    </button>
                                    <span class="count">{$answervo.vote_num}</span>
                                    <button type="button" class="hate" data-id="1020000005776083" data-type="answer" data-do="hate" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="答案没帮助，是错误的答案，答非所问">
                                        <span class="sr-only">答案没帮助，是错误的答案，答非所问</span>
                                    </button>
                                </div>
                            </div>

                            <div class="post-offset">
                                <div class="answer fmt" data-id="1020000005776083">
                                    <p>{$answervo.content}</p>
                                </div>        
                                <div class="row answer__info--row">
                                    <div class="post-opt col-md-8 col-sm-8 col-xs-10">
                                        <ul class="list-inline mb0">
                                            <li><a> <?php echo date("Y-m-d h:i:s",$answervo['create_time'])?>  回答</a> <span class="text-muted"></span></li>
                                            <li><a href="javascript:void(0);" class="comments" data-id="1020000005776083" data-target="#comment-1020000005776083">评论</a></li>
                                        </ul>
                                    </div>
                                    <div class="col-md-2 col-sm-2 col-xs-2 answer__info--author-avatar">
                                        <a class="mr10" href="/u/runforlove"><img class="avatar-32" src="__ROOT__/{$answervo.face}" alt=""></a>
                                    </div>
                                    <div class="col-md-2 col-sm-2 hidden-xs answer__info--author">
                                        <div class=" answer__info--author-warp">
                                            <a class="answer__info--author-name" title="菩提旭光" href="/u/runforlove">{$answervo.username}</a>
                                            <!-- <span class="answer__info--author-rank">892 声望</span> -->
                                        </div>
                                    </div>
                                </div>


                                <div class="widget-comments hidden" id="comment-1020000005776083" data-id="1020000005776083">
                                    <div class="widget-comments__form row">
                                        <div class="col-md-12">请先 <a class="commentLogin" href="javascript:void(0);">登录</a> 后评论</div>
                                    </div><!-- /.widget-comments__form -->
                                </div><!-- /.widget-comments -->
                            </div>
                        </article><!-- /article -->
                    </volist>
                    
                    <div class="text-center">
                    </div>
                </div><!-- /.widget-answers -->
                <div>
                    <h4>撰写答案</h4>
                    <input type="hidden" id="draftId" value="">
                    <input type="hidden" value="1010000005768307" id="questionId">
                    <form action="{:U('home/Blogs/submitAnswer')}" method="post" class="editor-wrap">
                        <!-- <div class="editor" id="questionText"> -->
                        
                        <input type="hidden" value="<?php echo $_GET['qid'] ?>" name="qid">
                        <div id="container"  placeholder="撰写答案..."></div>
                        <!-- </div> -->
                        <div id="answerSubmit" class="mt15 clearfix">
                            <div class="checkbox pull-left">
                                <label><input type="checkbox" class="" id="shareToWeibo">同步到新浪微博</label>
                            </div>
                            <div class="pull-right">
                                <span id="editorStatus" class="hidden text-muted"></span>
                                <a id="dropIt" href="javascript:void(0);" class="mr10 hidden">[舍弃]</a>
                                <button type="submit" id="answerIt" data-id="1010000005768307" class="btn btn-lg btn-primary ml20">提交回答</button>
                            </div>
                        </div>
                    </form>
                </div>
               
            </div>
            <!-- /.main -->

            <div class="col-xs-12 col-md-3 side">
                <div data-type="widget" data-api="/api/bookmarkArchive/hots" data-api-overwrite="/api/bookmarkArchive/1010000005768307/related">
                    <div class="widget-box widget-box--bookmark no-border">
                        <h4 class="widget-box__title">相关收藏夹 <a id="widgetBookmarkRefresh" class="userstab pull-right" href="javascript:;">换一组</a></h4>
                        <ul class="widget-links list-unstyled media">
                            <li class="widget-links__item">
                                <img class="pull-left pattern pattern-13 mr10" src="https://sf-static.b0.upaiyun.com/v-576b52d9/global/img/pattern/4.svg" width="32">
                                <div class="media-body">
                                    <a target="_blank" class="ellipsis mr0" href="/bookmark/1230000002879194">node</a>
                                    <p class="mb0">
                                        <span>9</span> 个条目 <span class="division">|</span> <span>0</span> 人关注
                                    </p>
                                </div>
                            </li>
                    
                            <li class="widget-links__item">
                                <img class="pull-left pattern pattern-11 mr10" src="https://sf-static.b0.upaiyun.com/v-576b52d9/global/img/pattern/8.svg" width="32">
                                <div class="media-body">
                                    <a target="_blank" class="ellipsis mr0" href="/bookmark/1230000003998558">nodejs</a>
                                    <p class="mb0">
                                        <span>240</span> 个条目 <span class="division">|</span> <span>0</span> 人关注
                                    </p>
                                </div>
                            </li>
                    
                            <li class="widget-links__item">
                                <img class="pull-left pattern pattern-11 mr10" src="https://sf-static.b0.upaiyun.com/v-576b52d9/global/img/pattern/9.svg" width="32">
                                <div class="media-body">
                                    <a target="_blank" class="ellipsis mr0" href="/bookmark/1230000003823169">nodejs</a>
                                    <p class="mb0">
                                        <span>15</span> 个条目 <span class="division">|</span> <span>0</span> 人关注
                                    </p>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>

                <div class="widget-box no-border">
                    <h2 class="h4 widget-box__title">相似问题</h2>
                    <ul class="widget-links list-unstyled">
                        <li class="widget-links__item">
                            <a title="Node.js Async.js结合node-mysql使用的疑问" href="/q/1010000004180541">Node.js Async.js结合node-mysql使用的疑问</a>
                            <small class="text-muted">1 回答</small>
                        </li>
                        <li class="widget-links__item">
                            <a title="node.js express mysql redis 你们是怎么分层的？" href="/q/1010000004571516">node.js express mysql redis 你们是怎么分层的？</a>
                        </li>
                        <li class="widget-links__item">
                            <a title="node.js用express连接MySQL出现了bug" href="/q/1010000004438635">node.js用express连接MySQL出现了bug</a>
                            <small class="text-muted">3 回答</small>
                        </li>
                        <li class="widget-links__item">
                            <a title="node.js mysql Cannot find module &amp;quot;net&amp;quot; 和 &amp;quot;tls&amp;quot;和&amp;quot;fs&amp;quot; 的问题" href="/q/1010000005762632">node.js mysql Cannot find module "net" 和 "tls"和"fs" 的问题</a>
                            <small class="text-muted">1 回答 | 已解决</small>
                        </li>
                        <li class="widget-links__item">
                            <a title="node.js 导入 mysql出问题" href="/q/1010000004693920">node.js 导入 mysql出问题</a>
                            <small class="text-muted">1 回答</small>
                        </li>
                        <li class="widget-links__item">
                            <a title="node-mysql如何获取某个表中全部字段" href="/q/1010000002726838">node-mysql如何获取某个表中全部字段</a>
                            <small class="text-muted">1 回答 | 已解决</small>
                        </li>
                        <li class="widget-links__item">
                            <a title="nodejs 使用node-mysql 中间件的普通连接与连接池连接哪个好？" href="/q/1010000000355170">nodejs 使用node-mysql 中间件的普通连接与连接池连接哪个好？</a>
                            <small class="text-muted">1 回答</small>
                        </li>
                        <li class="widget-links__item">
                            <a title="node-mysql在查询大数据时，怎么保证不会超时？" href="/q/1010000000455040">node-mysql在查询大数据时，怎么保证不会超时？</a>
                            <small class="text-muted">1 回答</small>
                        </li>
                        <li class="widget-links__item">
                            <a title="node 中的 node-mysql 大家是保持长连接还是短连接？" href="/q/1010000000454504">node 中的 node-mysql 大家是保持长连接还是短连接？</a>
                            <small class="text-muted">3 回答</small>
                        </li>
                        <li class="widget-links__item">
                            <a title="felixge/node-mysql 中.query()函数问题" href="/q/1010000004286883">felixge/node-mysql 中.query()函数问题</a>
                            <small class="text-muted">1 回答 | 已解决</small>
                        </li>
                    </ul>
                </div>

                <div class="widget-share__full" data-url="#" data-shorturl="#">
                    <div style="margin-bottom:10px;">分享扩散：</div>
                    <div class="widget-share-network sharer-0" style="display: block;">
                        <ul class="sn-inline">
                            <li data-network="weibo"><a href="javascript:void(0);" class="entypo-weibo icon-sn-weibo share-1" data-toggle="tooltip" data-placement="top" title="" data-original-title="分享至新浪微博">新浪微博</a></li>
                            <li data-network="wechart"><a href="javascript:void(0);" class="entypo-wechart icon-sn-weixin share-2" data-toggle="tooltip" data-placement="top" title="" data-original-title="分享至微信">微信</a></li>
                            <li data-network="twitter"><a href="javascript:void(0);" class="entypo-twitter icon-sn-twitter share-3" data-toggle="tooltip" data-placement="top" title="" data-original-title="分享至 Twitter">Twitter</a></li>
                            <li data-network="facebook"><a href="javascript:void(0);" class="entypo-facebook icon-sn-facebook share-4" data-toggle="tooltip" data-placement="top" title="" data-original-title="分享至 Facebook">Facebook</a></li>
                        </ul>
                    </div>
                    <a type="button" class="btn btn-sm shareMore btn-sn-more" data-toggle="popover" data-placement="top" data-url="#" data-shorturl="#"><span class="icon-sn-dotted" data-original-title="" title=""></span><strong class="visible-xs-inline">•••</strong></a>
                </div>
 
            </div><!-- /.side -->
        </div>
    </div>
</div>
<script type="text/javascript" src="__PUBLIC__/js/jquery-1.7.2.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        // $('.like,.hate').click(function(event) {
        //     if($('#setsession').val() == ''){
        //         if(confirm("请先登录") != false){
        //             location.href = '{:U("home/register/register")}';
        //         }else{
        //             return false;
        //         }
        //     }
        //     alert($(this).parent().attr('dataid'));
        // });
        //当问题被点赞或者被贬低的时候
        // setsession

        $('#answerIt').click(function(event) {
            if($('#setsession').val() == ''){
                if(confirm("请先登录") != false){
                    location.href = '{:U("home/register/register")}';
                    return false;
                }else{
                    return false;
                }
            }
        });

        $('#question_cate,#answer_cate').children('button').click(function(event) {
            if($('#setsession').val() == ''){
                if(confirm("请先登录") != false){
                    location.href = '{:U("home/register/register")}';
                }else{
                    return false;
                }
            }
            var thistype = $(this).parent().attr('clickType');    //判断点击的是问题的点赞还是回答的点赞
            var thisaction = $(this).attr('data-do');             //判断点击的是点赞还是贬低
            var thisques_answerID = $(this).parent('div').attr('dataid'); //得到对应的问题或回答的ID
            var thisobj = $(this);
            // alert("thetype=" + thistype  + ",theaction=" + thisaction);
            // return false;
            $.ajax({
                url: '{:U("home/Blogs/btnClick")}',
                type: 'POST',
                dataType: 'json',
                data: {thetype:thistype,theaction:thisaction,theid:thisques_answerID},
                success:function(data){
                    if(data.error == 0){
                        thisobj.siblings('span').html(data.vote_num);
                    }else{
                        alert(data.msg);
                    }
                },
                error:function(){

                }
            })
            
        });





    });

</script>

